/*************************************************************************
 Copyright (C) Unpublished Unis Software, Inc. All rights reserved.
 Unis Software, Inc., Confidential and Proprietary.

 This software is subject to copyright protection
 under the laws of the Public of China and other countries.

 Unless otherwise explicitly stated, this software is provided
 by Unis "AS IS".
 *************************************************************************/
package com.unis.web.account;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.beanutils.BeanUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.unis.common.util.WebUtil;
import com.unis.model.BaseModel;
import com.unis.model.account.SysPermitMenu;
import com.unis.service.account.SysPermitMenuService;

/**
 * @author CSJ (email:raulcsj@163.com)
 * @since 2012-12-11
 */
@Controller
@RequestMapping("/syspermitmenu")
public class SysPermitMenuController {

    private SysPermitMenuService syspermitmenuService;

    /****************************************
     * Insert a instace of SysPermitMenu
     ****************************************/
    @RequestMapping("/insert")
    @ResponseBody
    public Object insertSysPermitMenu(@RequestBody List<?> syspermitmenuList) throws Exception {
        String status = "failure";
        syspermitmenuService.batchInsert(syspermitmenuList);
        status = "success";
        return status;
    }

    /****************************************
     * Update a instace of SysPermitMenu
     ****************************************/
    @RequestMapping("/update")
    @ResponseBody
    public Object update(@RequestBody SysPermitMenu syspermitmenu) throws Exception {
        syspermitmenu.setStatmentId("SysPermitMenu.update");
        String status = "failure";
        syspermitmenuService.update(syspermitmenu);
        status = "success";
        return status;
    }

    /****************************************
     * Delete a instace of SysPermitMenu
     ****************************************/
    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(@RequestBody SysPermitMenu syspermitmenu) throws Exception {
        syspermitmenu.setStatmentId("SysPermitMenu.delete");
        String status = "failure";
        syspermitmenuService.batchDelete(syspermitmenu);
        status = "success";
        return status;
    }

    /****************************************
     * Query instaces of SysPermitMenu
     ****************************************/
    @RequestMapping("/queryAsList")
    @ResponseBody
    public Object queryAsList(HttpServletRequest request) throws Exception {
        Map<String, Object> paramMap = WebUtil.getParamsMapFromRequest(request);
        SysPermitMenu syspermitmenu = new SysPermitMenu();
        syspermitmenu.setPaging(false);
        syspermitmenu.setStatmentId("SysPermitMenu.queryAsList");
        BeanUtils.populate(syspermitmenu, paramMap);
        return syspermitmenuService.queryAsList(syspermitmenu);
    }

    /****************************************
     * Query a instaces of SysPermitMenu
     ****************************************/
    @RequestMapping("/queryAsObject")
    @ResponseBody
    public BaseModel queryAsObject(@RequestBody SysPermitMenu syspermitmenu) throws Exception {
        syspermitmenu.setStatmentId("SysPermitMenu.queryAsObject");
        return syspermitmenuService.queryAsObject(syspermitmenu);
    }

    @RequestMapping("/permitMenuMgr")
    public String permitMenuMgr() {
        return "sys/syspermitmenuList";
    }

    @Resource
    public void setSysPermitMenuService(SysPermitMenuService syspermitmenuService) {
        this.syspermitmenuService = syspermitmenuService;
    }
}
